<template>
  <div>
    <el-tabs type="border-card">
      <el-tab-pane label="用户列表">
        <el-form ref="form" size="mini" :model="userInfoForm" label-width="80px">
          <!-- <el-form-item label="病区">
            <el-select v-model="userInfoForm.name">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>-->
          <el-form-item label="床号">
            <el-input clearable v-model="userInfoForm.bch"></el-input>
          </el-form-item>
          <el-form-item label="姓名">
            <el-input clearable v-model="userInfoForm.brxm"></el-input>
          </el-form-item>
          <!-- <el-form-item label="诊号">
            <el-input clearable v-model="userInfoForm.zyh"></el-input>
          </el-form-item> -->
          <el-form-item label="就诊卡号">
            <el-input clearable v-model="userInfoForm.zyh"></el-input>
          </el-form-item>
          <!-- <el-form-item label="类别">
            <el-select v-model="userInfoForm.name">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>-->
          <el-form-item>
            <el-button type="primary" @click="search">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          @row-click="clickRow"
          :data="userInfoTable"
          height="350"
          border
          style="width: 100%"
        >
          <el-table-column prop="bch" label="床号" width="180"></el-table-column>
          <el-table-column prop="brxm" label="姓名" width="180"></el-table-column>
          <el-table-column prop="brxb" label="性别"></el-table-column>
          <el-table-column prop="ryzd" label="诊断"></el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="申请单查询">
        <el-form
          class="sqdForm"
          ref="form"
          size="mini"
          :model="form"
          label-width="80px"
        >
          <el-form-item label="开始日期">
            <el-date-picker
              clearable
              value-format="yyyy-MM-dd"
              size="mini"
              v-model="form.ksrq"
              type="date"
              placeholder="选择日期时间"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="结束日期">
            <el-date-picker
              clearable
              value-format="yyyy-MM-dd"
              size="mini"
              v-model="form.jsrq"
              type="date"
              placeholder="选择日期时间"
            ></el-date-picker>
          </el-form-item>
          <el-form-item class="flexItem" label="申请单号">
            <el-input clearable v-model="form.sqdh" size="mini"></el-input>
          </el-form-item>
          <el-form-item label="就诊卡号">
            <el-input v-model="form.name" size="mini"></el-input>
          </el-form-item>
          <el-form-item label="姓名">
            <el-input clearable v-model="form.brxm" size="mini"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="sqdSearch('form')">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="tableData" style="width: 100%" :height="leftTabHeight">
          <el-table-column prop="brxm" label="病人姓名" width="150"></el-table-column>
          <el-table-column prop="brxb" label="性别" width="120"></el-table-column>
          <el-table-column prop="brnl" label="年龄" width="120"></el-table-column>
        </el-table>
        <div class="block">
          <!-- <el-pagination
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            layout="prev, pager, next"
            :total="400"
            small
          ></el-pagination> -->
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
export default {
  data() {
    return {
      currentPage: 1,
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "3",
          city: "2",
          address: "1",
          zip: 200333,
        },
      ],
      leftTabHeight: window.innerHeight - 101 - 40 - 280 - 15 - 66,
      form: {
        name: "",
        brxm:'',
        jsrq:'',
        ksrq:'',
        sqdh:''
      },
      userInfoForm: {
        bch: "",
        brxm:'',
        zyh:'',
        tmh:''
      },
      userInfoTable: [],
    };
  },
  methods:{
    // //获取病人列表
    // getBrxxList(){
    //   this.$ajax.get(`/yx/getBrxxList?hisdeptid=${this.$cookies.get('userInfo').deptid}&zyh=`,{}).then(res => {
    //     if (res.code == "0") {
    //       this.userInfoTable = res.data
    //     }
    //   })
    // },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    clickRow(row, column, event){
      this.$emit('userInfo',row)
    },
    search(){
      this.$ajax.get(`/yx/searchBrxxByMany?bch=${this.userInfoForm.bch}&brxm=${this.userInfoForm.brxm}&deptid=${this.$cookies.get('userInfo').deptid}&tmh=${this.userInfoForm.tmh}`,{}).then(res => {
        if (res.code == "0") {
          this.userInfoTable = res.data
        }
      })
    },
    sqdSearch(){
      if (this.form.jsrq == "") {
        this.form.jsrq = "2200-12-21"
      }
      if (this.form.ksrq == "") {
        this.form.ksrq = "1990-12-21"
      }
      this.$ajax.get(`/yx/searchSqdhByMany?brxm=${this.form.brxm}&deptid=${this.$cookies.get('userInfo').deptid}&jsrq=${this.form.jsrq}&ksrq=${this.form.ksrq}&sqdh=${this.form.sqdh}`,{}).then(res => {
        if (res.code == "0") {
          this.tableData = res.data
        }
      })
    },
    searchAll(){
      this.$ajax.get(`/yx/getBrxxList?hisdeptid=${this.$cookies.get('userInfo').deptid}&zyh=`,{}).then(res => {
        if (res.code == "0") {
          this.userInfoTable = res.data
        }
      })
    }
  },
  mounted(){
    this.searchAll()
    this.sqdSearch()
  }
};
</script>
<style lang="less" scoped>
.sqdForm {
  .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 175px;
  }
}
.el-form-item {
  margin-bottom: 5px;
}
</style>